import http from '@/utils/request'

const apiBefore = 'web/reports'

export const mapping = {

  addTemplate: params => {
    return http.post(`${apiBefore}/sys/finance/account/save`, params)
  },
  requstTempList: params => {
    return http.get(`${apiBefore}/sys/finance/account/list`, { params })
  },
  deleteTemp: params => {
    return http.put(`${apiBefore}/sys/finance/account/delete`, params)
  },
  copyFromTemp: params => {
    return http.put(`${apiBefore}/sys/finance/account/copy`, params)
  },
  ipdateTemp: params => {
    return http.put(`${apiBefore}/sys/finance/account/${params}/update`)
  },
  addAccount: params => {
    return http.post(`${apiBefore}/sys/finance/item/save`, params)
  },
  updateAccount: (params, id) => {
    return http.put(`${apiBefore}/sys/finance/item/${id}/update`, params)
  },
  requstAccountList: params => {
    return http.get(`${apiBefore}/sys/finance/item/tree`, { params })
  },
  deleteAccountItem: params => {
    return http.post(`${apiBefore}/sys/finance/item/delete`, params)
  },
  getMappingSourceTree: params => {
    return http.get(`${apiBefore}/sys/finance/mapping/source-tree`, { params })
  },
  getMappingTree: params => {
    return http.get(`${apiBefore}/sys/finance/mapping/mapping-tree`, { params })
  },
  saveMappingTree: params => {
    return http.post(`${apiBefore}/sys/finance/mapping/save`, params)
  },
  deleteMappingItem: params => {
    return http.post(`${apiBefore}/sys/finance/mapping/delete`, params)
  },
  updateMappingItem: params => {
    return http.post(`${apiBefore}/sys/finance/item/update-order`, params)
  },
  getReportIntegration: params => {
    return http.get(`${apiBefore}/sys/finance/account/report-integration`, { params })
  },
  sharedTemp: params => {
    return http.post(`${apiBefore}/sys/finance/account/saveShareFinance`, params)
  },
  addBuiltIn: params => {
    return http.put(`${apiBefore}/sys/finance/account/copyOnBuiltIn`, params)
  },
  saveDefaultTemplate:params=>{
    return http.post(`web/um/sys/user-setting`,params)
  },
  getDefaultTemplate:params=>{
    return http.get(`/web/um/sys/user-setting?userId=${params.userId}&keyword=account.mapping.default.template`,params)
  }
}
